<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // 改变promise状态和指定回调函数谁先谁后?
        //   resolve          then
        //1. 先改变状态, 然后指定回调
        // let p = new Promise((resolve, reject) => {
        //     resolve('ok');
        // });

        // //指定回调
        // p.then(v => {
        //     console.log(v);
        // })

        //2. 先指定回调, 再改变状态
        let p = new Promise((resolve, reject) => {
            setTimeout(() => {
                resolve('ok');
            }, 1000);
        });

        //指定回调
        p.then(v => {
            console.log(v);
        })
    
    </script>
</body>
</html>